<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <title>Login</title>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="icon" href="data:;base64,iVBORw0KGgo=" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script defer src="/web/js/alpinejs@3.14.1.min.js"></script>
    <link rel="stylesheet" href="/web/css/bootstrap@5.3.3.min.css" />
  </head>

  <body>
    <table class="table table-borderless">
      <thead>
        <tr>
          <th scope="col">#</th>
          <th scope="col">账号</th>
          <th scope="col">姓名</th>
          <th scope="col">昵称</th>
          <th scope="col">手机号</th>
        </tr>
      </thead>
      <tbody>
        <tr x-data="data()" x-init="getData()">
          <th scope="row" x-text="data.id"></th>
          <td x-text="data.account"></td>
          <td x-text="data.name"></td>
          <td x-text="data.nickname"></td>
          <td x-text="data.telephone"></td>
        </tr>
      </tbody>
    </table>

    <script>
      function data() {
        return {
          data: "",
          async getData() {
            const response = await fetch("/api/v1/user");
            const data = await response.json();
            if (data.msg !== "") {
              alert(data.msg);
              window.location.href = "/web/login.html";
            }
            this.data = data.data;
          },
        };
      }
    </script>
  </body>
</html>
